#pragma once

#include "DDSafeDelete.h"

#include "..\..\RayCtrlMan\RayPlugHeader.h"
#include "..\..\..\src\DDPublic\PlugReg.h"

#include "..\..\PLCCtrlMan\comaccess.h"

class xhYXXray : public RayPlug, public PlugReg
{
public:
	xhYXXray(void);
	~xhYXXray(void);

public:
	virtual int Initialize();
	//
	virtual int OpParam(void *pVoid = NULL);
	//

	virtual int SetComCfg(zkComCfg *pCfg);
	virtual int CheckConnect(int &nStatus);

	virtual int SetRayCfg(zkRayCfg *pCfg);

	virtual int SetRayCtrl(zkRayCtrl *pRayCtrl,BOOL bWaitToGo = FALSE);
	virtual int GetRayCtrl(zkRayCtrl **ppRayCtrl);

private:
	int  StartRadialData(zkRayCtrl *pRayCtrl,BOOL bWaitToGo = FALSE);
	void StopRadialData();
	void CalVoltageString(float fVoltage,BYTE *pBuffer,int &nLen);
	void CalAmpereString(float fAmpere,BYTE *pBuffer,int &nLen);

	void AddEnterToString(BYTE *pBuffer,int &nLen);
	void AddStrToString(char *pCfg,BYTE *pBuffer,int &nLen);

private:
	int WriteCommand(char *pszCmd);

private:
	zkComCfg  m_xComCfg;
    zkRayCfg  m_xRayCfg;
	BOOL      m_bValid;

private:
	int m_nConnectState;
	
private:
	zkRayCtrl m_RealRayCtrl;
	zkRayCtrl m_xOutRayCtrl;

private:
	ComAccess m_xCom;
};
